package com.designpattern.factory.simplefactory;

/**
 * @author liyanhao
 * @Date 2023-02-06 23:43
 * 简单工厂类
 */
public class SimpleFactory {
    //添加orderType返回对应的Pizza对象
    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("简单工厂模式");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if (orderType.equals("pepper")) {
            pizza = new CheesePizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;
    }
}
